package com.lianzhihui.romeex.mvp.model;

import android.content.Context;

import com.lianzhihui.romeex.R;
import com.lianzhihui.romeex.bean.BindExchangeBean;
import com.lianzhihui.romeex.bean.SunTeamAwardBean;
import com.lianzhihui.romeex.bean.user.CountryCode;
import com.lianzhihui.romeex.bean.user.WalletInfo;
import com.lianzhihui.romeex.net.APIConstant;
import com.lianzhihui.romeex.net.HttpManager;
import com.lianzhihui.romeex.net.HttpManagerCallback;
import com.lianzhihui.romeex.net.ResultData;
import com.lianzhihui.romeex.utils.GsonUtil;
import com.lianzhihui.romeex.utils.LogUtil;
import com.lianzhihui.romeex.utils.MyToast;
import com.zhouyou.http.exception.ApiException;
import com.zhouyou.http.model.HttpParams;

import java.util.List;

//网络数据请求实现
public class EarningsModelImp {
    private Context context;
    EarningsModelInterface earningsModelInterface;

    public EarningsModelImp(Context context, EarningsModelInterface loginModelInterface) {
        this.context = context;
        this.earningsModelInterface = loginModelInterface;
    }


    public void requestSunTeamAward(int page, int pageSize) {
        HttpParams params = new HttpParams();
        params.put("page", String.valueOf(page));
        params.put("pageSize", String.valueOf(pageSize));
        new HttpManager(context, new HttpManagerCallback() {
            @Override
            public void onSuccess(ResultData o) {
                if (o.getCode() == 200) {
                    SunTeamAwardBean bean = GsonUtil.GsonToBean(o.getData(), SunTeamAwardBean.class);
                    earningsModelInterface.responseSunTeamAwardSuccess(bean);
                } else {
                    MyToast.showToast(o.getData().getAsString());
                    earningsModelInterface.onFailure();
                }
            }

            @Override
            public void onError(ApiException e) {
                MyToast.showToast(e.getMessage());
                earningsModelInterface.onFailure();
            }
        }).post(APIConstant.SUN_TEAMAWARD, params);
    }
}
